package org.particlethink.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.particlethink.entry.PlanTyp;
import org.particlethink.model.PlanMaterial;

import java.util.List;

@Mapper
public interface PlanMaterialMapper extends tk.mybatis.mapper.common.Mapper<PlanMaterial> {


    void batchInsert(@Param("list") List<PlanMaterial> planMaterials);

    void BatchUpdateOrderID(@Param("orderId") int orderId, @Param("planMaterialIds") List<Integer> planMaterialIds);

    @Select("select * from plan_materials where order_id = #{orderId}")
    List<PlanMaterial> selectByOrderID(@Param("orderId") int orderId);


    void updateCompleteNum(@Param("planMaterials") List<PlanMaterial> planMaterials);
    void updateActualAndCompleteNum(@Param("planMaterials") List<PlanMaterial> planMaterials);

    void updateExpectNum(@Param("planMaterials") List<PlanMaterial> planMaterials);

    void updateActualNum(@Param("planMaterials") List<PlanMaterial> planMaterials);


    List<PlanMaterial> selectByPlanIDsAndTyp(@Param("planIds") List<Integer> planIds, @Param("type") PlanTyp type);

    List<PlanMaterial> selectByPlanIDAndTyp(@Param("planId") Integer planId, @Param("type") PlanTyp type);

    List<PlanMaterial> selectByIds(@Param("list") List<Integer> ids);

    void deleteByPlanIDAndTyp(@Param("planId") Integer planId, @Param("type") PlanTyp type);

    void deleteByPlanIDAndTypAndMaterialIds(@Param("planId") Integer planId, @Param("type") PlanTyp type, @Param("list") List<Integer> materialIds);

    void batchInsertOrUpdate(@Param("list") List<PlanMaterial> planMaterials);
}
